home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / ODF / Found / FWCommon / FWStdDef.h < prev    next >
Encoding:
Text File  |  1996-12-16  |  6.1 KB  |  258 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWStdDef.h
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWSTDDEF_H
  11. #define FWSTDDEF_H
  12.  
  13. #ifndef FWENVDEF_H
  14. #include "FWEnvDef.h"
  15. #endif
  16.  
  17. #ifndef FWERRORS_H
  18. #include "FWErrors.h"
  19. #endif
  20.  
  21. #if defined(FW_BUILD_MAC) & !defined(__TYPES__)
  22. #include <Types.h>
  23. #endif
  24.  
  25. #if defined(FW_BUILD_MAC) & !defined(__FRAGRSRC__)
  26. #include "FragRsrc.h"
  27. #endif
  28.  
  29. #if defined(FW_BUILD_MAC) & !defined(__LOWMEM__)
  30. #include <LowMem.h>
  31. #endif
  32.  
  33. #if defined FW_BUILD_MAC  && !defined __FILES__
  34. #include <Files.h>
  35. #endif
  36.  
  37. #if defined FW_BUILD_MAC && !defined __QUICKDRAW__
  38. #include <Quickdraw.h>
  39. #endif
  40.  
  41. #if defined FW_BUILD_WIN
  42. #define STRICT
  43. #define WIN32_LEAN_AND_MEAN
  44. #define WIN32_EXTRA_LEAN
  45. #include <windows.h>
  46.  
  47. //    [jkp] 961009
  48. //    This file defines SOMLINK and SOMDLINK.  We should not define our 
  49. //    own flavors for these because OpenDoc for windows has certain
  50. //    expectations to which we must conform.
  51. #include <somltype.h>
  52. #endif
  53.  
  54. FW_EXTERN_C_BEGIN
  55.  
  56. /*========================================================================================
  57. /  Build system macro definitions
  58. /========================================================================================*/
  59.  
  60. /*----------------------------------------------------------------------------------------
  61. /
  62. /     The macro SL_API is used to define more effecient calling convention for the Windows
  63. /    version    of the ODF shared library (SL).  It should be used like this:
  64. /
  65. /    void*    SL_APL    FW_OhWellWhateverNevermind(long l, short s);
  66. /
  67. /----------------------------------------------------------------------------------------*/
  68.  
  69. #ifdef FW_BUILD_MAC
  70.     #define SL_API
  71. #endif
  72.  
  73. #ifdef FW_BUILD_WIN
  74.     #define    SL_API            __stdcall
  75. #endif
  76.  
  77. #ifndef SOMCHKEXCEPT
  78. #define SOMCHKEXCEPT You_forgot_to_include_FWODExce_has_the_first_header_in your__cpp
  79. #endif
  80.  
  81. /*========================================================================================
  82. // Define OpenDoc version number so we can use appropriate interface
  83. /========================================================================================*/
  84.  
  85. #ifndef FW_OPENDOC_VERSION
  86.  
  87. #define FW_OPENDOC_DR1    1
  88. #define FW_OPENDOC_DR2    2
  89. #define FW_OPENDOC_DR3    3
  90. #define FW_OPENDOC_DR4    4
  91. #define FW_OPENDOC_100    FW_OPENDOC_DR4
  92. #define FW_OPENDOC_101    5
  93. #define FW_OPENDOC_110    6
  94.  
  95. #ifdef FW_BUILD_MAC
  96. #define FW_OPENDOC_VERSION     FW_OPENDOC_110
  97. #endif
  98.  
  99. #ifdef FW_BUILD_WIN
  100. #define FW_OPENDOC_VERSION     FW_OPENDOC_DR4
  101. #endif
  102.  
  103. #endif
  104.  
  105. /*========================================================================================
  106. /  Type definitions
  107. /========================================================================================*/
  108.  
  109. #ifndef FW_COMPILER_SUPPORTS_BOOL
  110. //typedef unsigned char bool;
  111. #define false 0
  112. #define true 1
  113. #endif
  114.  
  115. typedef     unsigned char    FW_Boolean;
  116.  
  117. // typedef used as return value for functions that need to indicate whether
  118. // a dispatched event should be propogated further down a handler chain
  119.  
  120. typedef     FW_Boolean        FW_Handled;
  121. #define        FW_kHandled        TRUE
  122. #define        FW_kNotHandled    FALSE
  123.  
  124. // FW_Message is defined in "FWNotDef.h" which may be included by resource files
  125. // typedef     long            FW_Message; 
  126.  
  127. // ----- Macintosh -----
  128. #ifdef FW_BUILD_MAC
  129.  
  130. typedef     short             FW_ResourceID;
  131.  
  132. typedef     char**             FW_PlatformHandle;
  133.  
  134. typedef     unsigned long     FW_ResourceType;
  135.  
  136. struct FW_SCodeFragRefFile
  137. {
  138.     CFragResFileRef    fFragRef;            // Reference to resource map
  139.     short            fRefNum;            // RefNum of resource file
  140.     long            fNesting;            // Nesting level (>0 means in use)
  141. };
  142.  
  143. typedef     FW_SCodeFragRefFile* FW_Instance;
  144.  
  145. typedef     double_t         FW_Double;
  146.  
  147. typedef     Rect            FW_PlatformRect;
  148. typedef     Point            FW_PlatformPoint;
  149. typedef        short            FW_PlatformCoordinate;
  150.  
  151. #endif
  152.  
  153.  
  154. // ----- Windows -----
  155. #ifdef FW_BUILD_WIN
  156.  
  157. typedef     unsigned short     FW_ResourceID;
  158.  
  159. typedef        HANDLE             FW_PlatformHandle;
  160.  
  161. typedef     unsigned short     FW_ResourceType;
  162.  
  163. typedef     HINSTANCE         FW_Instance;
  164.  
  165. typedef     double             FW_Double;
  166.  
  167. typedef     RECT            FW_PlatformRect;
  168. typedef     POINT            FW_PlatformPoint;
  169.  
  170. #ifdef FW_BUILD_WIN32
  171. typedef        long            FW_PlatformCoordinate;
  172. #endif
  173. #ifdef FW_BUILD_WIN16
  174. typedef        int                FW_PlatformCoordinate;
  175. #endif
  176.  
  177. #endif
  178.  
  179. /*========================================================================================
  180. /  Mac A5 Globals
  181. /========================================================================================*/
  182.  
  183. #ifdef FW_BUILD_MAC
  184.  
  185. #define FW_QDGlobals (*(QDGlobals*)( *(char**)LMGetCurrentA5() \
  186.                             - sizeof(QDGlobals) + sizeof(GrafPtr)))
  187. #endif
  188.  
  189. /*========================================================================================
  190. /  Constants
  191. /========================================================================================*/
  192.  
  193. #ifndef NULL
  194. #define NULL 0
  195. #endif
  196.  
  197. #ifndef FALSE
  198. #define FALSE 0
  199. #endif
  200.  
  201. #ifndef TRUE
  202. #define TRUE 1
  203. #endif
  204.  
  205. /*========================================================================================
  206. /  Macros
  207. /========================================================================================*/
  208.  
  209. #define FW_UNUSED(x)    ((void) &x)
  210.  
  211. FW_EXTERN_C_END
  212.  
  213. //========================================================================================
  214. //  Minimum and maximum functions
  215. //========================================================================================
  216.  
  217. #if 0
  218.  
  219. #define FW_PRIV_DEFINE_MIN_MAX(t)            \
  220.     inline t FW_Minimum(t a, t b)            \
  221.         {    return a < b ? a : b;    }        \
  222.     inline t FW_Maximum(t a, t b)            \
  223.         {    return a > b ? a : b;    }
  224.         
  225. #define FW_PRIV_DEFINE_ABS(t)                \
  226.     inline t FW_Absolute(t a)                \
  227.         {    return a < 0 ? -a : a; }
  228.  
  229. FW_PRIV_DEFINE_MIN_MAX(short)
  230. FW_PRIV_DEFINE_ABS(short)
  231.  
  232. FW_PRIV_DEFINE_MIN_MAX(unsigned short)
  233.  
  234. FW_PRIV_DEFINE_MIN_MAX(int)
  235. FW_PRIV_DEFINE_ABS(int)
  236.  
  237. FW_PRIV_DEFINE_MIN_MAX(unsigned int)
  238.  
  239. FW_PRIV_DEFINE_MIN_MAX(long)
  240. FW_PRIV_DEFINE_ABS(long)
  241.  
  242. FW_PRIV_DEFINE_MIN_MAX(unsigned long)
  243.  
  244. #else
  245.  
  246. template <class t>
  247. inline t FW_Minimum(t a, t b) { return a < b ? a : b; }
  248.  
  249. template <class t>
  250. inline t FW_Maximum(t a, t b) { return a > b ? a : b; }
  251.  
  252. template <class t>
  253. inline t FW_Absolute(t a) { return a < 0 ? -a : a; }
  254.  
  255. #endif
  256.  
  257. #endif
  258.